require('dotenv').config()
import { ValidationPipe } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { AppExceptionFilter } from './core/app.exception.filter'
import { PostInterceptor } from './core/post.interceptor'

async function bootstrap() {

  console.log(process.env)

  const app = await NestFactory.create(AppModule)

  app.useGlobalFilters(new AppExceptionFilter())
  app.useGlobalInterceptors(new PostInterceptor())
  app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }))

  if (process.env.Web_EnableCors === 'true') {
    app.enableCors({
      origin: 'http://localhost:8080',
      credentials: true
    })
  }

  await app.listen(3000)
}
bootstrap()
